#ifndef __ZUISCROLLBAR_H__
#define __ZUISCROLLBAR_H__

#include "ZControl.h"

namespace ZuiLib
{
class ZContainer;

class ZScrollBar:public ZControl
{
public:
	ZUI_CLASS_NAME("zui.ScrollBar");

	ZScrollBar(void);
	~ZScrollBar(void);


	const char* GetClass() const ZOVERRIDE;
	void* GetInterface(const char* pstrName) ZOVERRIDE;

	ZContainer* GetOwner() const;
	void SetOwner(ZContainer* pOwner);

	void SetVisible(bool bVisible = true) ZOVERRIDE;
	void SetEnabled(bool bEnable = true) ZOVERRIDE;
	void SetFocus() ZOVERRIDE;

	bool IsHorizontal();
	void SetHorizontal(bool bHorizontal = true);
	int GetScrollRange() const;
	void SetScrollRange(int nRange);
	int GetScrollPos() const;
	void SetScrollPos(int nPos);
	int GetLineSize() const;
	void SetLineSize(int nSize);

	bool GetShowButton1();
	void SetShowButton1(bool bShow);
	const char* GetButton1NormalImage();
	void SetButton1NormalImage(const char* pStrImage);
	const char* GetButton1HotImage();
	void SetButton1HotImage(const char* pStrImage);
	const char* GetButton1PushedImage();
	void SetButton1PushedImage(const char* pStrImage);
	const char* GetButton1DisabledImage();
	void SetButton1DisabledImage(const char* pStrImage);

	bool GetShowButton2();
	void SetShowButton2(bool bShow);
	const char* GetButton2NormalImage();
	void SetButton2NormalImage(const char* pStrImage);
	const char* GetButton2HotImage();
	void SetButton2HotImage(const char* pStrImage);
	const char* GetButton2PushedImage();
	void SetButton2PushedImage(const char* pStrImage);
	const char* GetButton2DisabledImage();
	void SetButton2DisabledImage(const char* pStrImage);

	const char* GetThumbNormalImage();
	void SetThumbNormalImage(const char* pStrImage);
	const char* GetThumbHotImage();
	void SetThumbHotImage(const char* pStrImage);
	const char* GetThumbPushedImage();
	void SetThumbPushedImage(const char* pStrImage);
	const char* GetThumbDisabledImage();
	void SetThumbDisabledImage(const char* pStrImage);

	const char* GetRailNormalImage();
	void SetRailNormalImage(const char* pStrImage);
	const char* GetRailHotImage();
	void SetRailHotImage(const char* pStrImage);
	const char* GetRailPushedImage();
	void SetRailPushedImage(const char* pStrImage);
	const char* GetRailDisabledImage();
	void SetRailDisabledImage(const char* pStrImage);

	const char* GetBkNormalImage();
	void SetBkNormalImage(const char* pStrImage);
	const char* GetBkHotImage();
	void SetBkHotImage(const char* pStrImage);
	const char* GetBkPushedImage();
	void SetBkPushedImage(const char* pStrImage);
	const char* GetBkDisabledImage();
	void SetBkDisabledImage(const char* pStrImage);

	void SetPos(RECT rc) ZOVERRIDE;
	void DoEvent(TEventUI& event) ZOVERRIDE;
	void SetAttribute(const char* pstrName, const char* pstrValue) ZOVERRIDE;

	void DoPaint(ZRenderer* render, const RECT& rcPaint) ZOVERRIDE;

	void PaintBk(ZRenderer* render);
	void PaintButton1(ZRenderer* render);
	void PaintButton2(ZRenderer* render);
	void PaintThumb(ZRenderer* render);
	void PaintRail(ZRenderer* render);


//signal:
	sigslot::signal1<int> SignalValueChange;
protected:
	void ScrollUpTimer(int);
	void ScrollDownTimer(int);

	enum { 
		DEFAULT_SCROLLBAR_SIZE = 10,
		DEFAULT_TIMERID = 10,
	};

	bool m_bHorizontal;
	int m_nRange;
	int m_nScrollPos;
	int m_nLineSize;
	ZContainer* m_pOwner;
	POINT ptLastMouse;
	int m_nLastScrollPos;
	int m_nLastScrollOffset;
	int m_nScrollRepeatDelay;

	ZImageDrawInfo m_sBkNormalImage;
	ZImageDrawInfo m_sBkHotImage;
	ZImageDrawInfo m_sBkPushedImage;
	ZImageDrawInfo m_sBkDisabledImage;

	bool m_bShowButton1;
	RECT m_rcButton1;
	uint32_t m_uButton1State;
	ZImageDrawInfo m_sButton1NormalImage;
	ZImageDrawInfo m_sButton1HotImage;
	ZImageDrawInfo m_sButton1PushedImage;
	ZImageDrawInfo m_sButton1DisabledImage;

	bool m_bShowButton2;
	RECT m_rcButton2;
	uint32_t m_uButton2State;
	ZImageDrawInfo m_sButton2NormalImage;
	ZImageDrawInfo m_sButton2HotImage;
	ZImageDrawInfo m_sButton2PushedImage;
	ZImageDrawInfo m_sButton2DisabledImage;

	RECT m_rcThumb;
	uint32_t m_uThumbState;
	ZImageDrawInfo m_sThumbNormalImage;
	ZImageDrawInfo m_sThumbHotImage;
	ZImageDrawInfo m_sThumbPushedImage;
	ZImageDrawInfo m_sThumbDisabledImage;

	ZImageDrawInfo m_sRailNormalImage;
	ZImageDrawInfo m_sRailHotImage;
	ZImageDrawInfo m_sRailPushedImage;
	ZImageDrawInfo m_sRailDisabledImage;
};


}//namespace
#endif

